#ifndef YXTHREADPOOL_H
#define YXTHREADPOOL_H

#include <pthread.h>
#include "LinkedList.h"

typedef struct {
    int             thread_num;
    pthread_t      *threads;
    pthread_mutex_t lock;
    pthread_cond_t  cond;
    LinkedList     *task_list;
    int             shutdown;
} ThreadPool;

typedef struct {
    void  (*function)(void *);
    void *arg;
} Task;

ThreadPool *yxThreadPoolCreate(int threadNum);
void        yxThreadFunction(ThreadPool *pool);
void        yxThreadPoolAddTask(ThreadPool *pool, void (*function)(void *), void *arg);

#endif // YXTHREADPOOL_H
